package com.guhus.ec.controller.seller;

import com.google.gson.Gson;
import com.guhus.ec.pojo.seller.Product;
import com.guhus.ec.service.seller.ProductService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class ProductController {
    @Autowired
    ProductService productService;


    @ResponseBody
    @RequestMapping("/selectAllProducts")
    public List<Product> selectAllProducts() {
        return productService.selectAllProducts();
    }

    @RequestMapping("/deleteProductById")
    public void deleteProductById(@RequestParam Integer id) {
        productService.deleteProductById(id);
    }

    @ResponseBody
    @RequestMapping("/selectProductById")
    public Product selectProductById(@RequestParam Integer id) {
        return productService.selectProductById(id);
    }
}
